package com.putao.album.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.putao.album.ahibernate.dao.AhibernateDao;
import com.putao.album.db.tables.InMessage;

import java.util.List;
import java.util.Map;

/**
 * Created by jidongdong on 15/5/14.
 */
public class MessageHelper {
    private Context mContext;
    private DatabaseHelper mDatabaseHelper;
    private SQLiteDatabase mSQLiteDatabase;
    private AhibernateDao<InMessage> mInMessage;

    public MessageHelper(Context ctx) {
        this.mContext = ctx;
        this.mDatabaseHelper = DatabaseHelper.getInstance();
        this.mSQLiteDatabase = mDatabaseHelper.getWritableDatabase();
        this.mInMessage = new AhibernateDao<InMessage>(this.mSQLiteDatabase);
    }

    public List<InMessage> getInMessageByWhere(Map<String, String> where) {
        List<InMessage> InMessageList = mInMessage.queryList(InMessage.class, where);
        return InMessageList;
    }

    public List<InMessage> getInMessage(InMessage sample) {
        List<InMessage> InMessageList = mInMessage.queryList(sample);
        return InMessageList;
    }

    public int addInMessage(InMessage sample) {
        return mInMessage.insert(sample);
    }

    public void updateInMessage(InMessage sample, Map<String, String> where) {
        mInMessage.update(sample, where);
    }

    public void deleteInMessage(Map<String, String> where) {
        mInMessage.delete(InMessage.class, where);
    }
}
